#ifndef FORMAT_H
#define FORMAT_H

#include "component.h"
#include <map>
#include <QString>
#include "utils.h"

class Format;

struct SubFormat {
    FERange range;
    void *context;
    FreeContext free;
    Format *format;
};

class Format {
public:
    Format(QString name, QString lib, std::map<QString, Format *>subs);

    QString name();

    int getSubFormats(FERange range, void *context, std::vector<SubFormat> &sub_formats);

    //Structure View
    FEField *getTopField();

    bool isAtomField(FEField *field);
    QString getFieldName(FEField *field);
    QString getNodeValue(FEFieldNode node);
    int64_t dessectField(FERange range, void *context, FEField *field, FEList *list);

//    void *createContext();
//    int destroyContext(void *context);
//    bool supportVideoView();
//    bool supportAudioView();
//    bool supportImageView();

//    int getViewTree(char *file_name);
//    int getStructure();//structure view
//    int getFrame(void *context, int frame_num);//video view
//    int getImage();//image view
//    int getWave();//audio view

private:
    QString name_;

    FEFormat *format_{nullptr};
//    decltype(get_video_summary) *get_video_summary_{nullptr};
//    decltype(get_video_frame) *get_video_frame_{nullptr};
//    decltype(get_audio_summary) *get_audio_summary_{nullptr};
//    decltype(get_audio_frame) *get_audio_frame_{nullptr};
//    decltype(get_image_image) *get_image_image_{nullptr};

    FEField *top_field_{nullptr};
    std::map<QString, Format *> sub_formats_;
};

#endif // FORMAT_H
